<ui:composition template="/template/twocolumn2.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="conteudo">
	   <div id="form_style">
		<h3>lista de disciplinas</h3>
		<h:form id="form">
		<f:event listener="#{disciplinaMB.inicializaAlteracao}" type="preRenderView" />
		 <p:messages id="messages" showDetail="false" autoUpdate="true" closable="true" />  
			
			<p:dataTable value="#{disciplinaMB.disciplinas}" var="disciplina" editable="true">
                 <f:facet name="header">  
                     Disiciplinas
                 </f:facet>  
                   <p:ajax event="rowEdit" listener="#{disciplinaMB.alterarDisciplina}" update=":form:messages" />  
                   <p:ajax event="rowEditCancel" listener="#{disciplinaMB.cancelaAlterarDisciplina}" update=":form:messages" />  
				<p:column headerText="nome">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{disciplina.nome}" />
						</f:facet>
						<f:facet name="input">
							<h:inputText value="#{disciplina.nome}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="status">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{disciplina.statusDescricao.valor}" />
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu style="width:100%" id="status"
								value="#{disciplinaMB.statusDisciplina}">
								<f:selectItem itemLabel="-- Selecione --"
									noSelectionOption="true" />
								<f:selectItems value="#{disciplinaMB.statusItens}"
									var="status" itemLabel="#{status.valor}"
									itemValue="#{status.chave}" />
							</p:selectOneMenu>
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="professor">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{disciplina.professor.nome}" />
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu style="width:100%"
								value="#{disciplinaMB.matriculaProfessor}" id="professor">
								<f:selectItem itemLabel="-- Selecione --"
									noSelectionOption="true" />
								<f:selectItems value="#{disciplinaMB.professores}"
									var="professor" itemLabel="#{professor.nome}"
									itemValue="#{professor.matricula}" />
							</p:selectOneMenu>
						</f:facet>
					</p:cellEditor>
				</p:column>
				
				<p:column headerText="curso">
                    <p:cellEditor>
                        <f:facet name="output">
			                 <h:outputText value="#{disciplina.curso.nome}" />
						</f:facet>
                        <f:facet name="input">
					      <p:selectOneMenu style="width:100%" 
                           value="#{disciplinaMB.cursoSelecionado}" id="curso">
                             <f:selectItem itemLabel="-- Selecione --"
                                 noSelectionOption="true" />
                             <f:selectItems value="#{disciplinaMB.cursos}"
                                var="curso" itemLabel="#{curso.nome}"
                                itemValue="#{curso.idCurso}" />
                          </p:selectOneMenu>
						</f:facet>
                    </p:cellEditor>
                </p:column>

		       <p:column style="width:6%">  
		            <p:rowEditor />  
		        </p:column>  

			</p:dataTable>

		</h:form>
		</div>
	</ui:define>
</ui:composition>
